var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
// var logger = require('morgan');


//梁徐超的 router服务
{
var lxcgouwucheRouter = require('./routes/lxcjs/lxcgouwuche');
var lxcgouwuchekongRouter = require('./routes/lxcjs/lxcgouwuchekong');
var lxcczzhifuRouter = require('./routes/lxcjs/lxcczzhifu');
var lxcchenggongdingdanRouter = require('./routes/lxcjs/lxcchenggongdingdan');
var lxcjifenshangchengRouter = require('./routes/lxcjs/lxcjifenshangcheng');
var lxcCGjoingouwucheRouter = require('./routes/lxcjs/lxcCGjoingouwuche');
var lxcdengdaizhifuRouter = require('./routes/lxcjs/lxcdengdaizhifu');
var lxcdingdanshouhuodizhiRouter = require('./routes/lxcjs/lxcdingdanshouhuodizhi');
var lxclibaiwuRouter = require('./routes/lxcjs/lxclibaiwu');
var lxcquerendingdanxinxiRouter = require('./routes/lxcjs/lxcquerendingdanxinxi');
var lxcshangjiaRouter = require('./routes/lxcjs/lxcshangjia');
var lxcshangjiabupeisongRouter = require('./routes/lxcjs/lxcshangjiabupeisong');
var lxcxiugaidizhiRouter = require('./routes/lxcjs/lxcxiugaidizhi');
var lxczhifuchenggongpsdRouter = require('./routes/lxcjs/lxczhifuchenggongpsd');
var lxcsanjiliandongRouter = require('./routes/lxcjs/lxcsanjiliandong');
}
//文博的 router服务
var lwbpersoncenterRouter = require('./routes/lwbpersoncenter');



//逸林的 router服务
var jfspxqRouter = require('./routes/yylindex');
var zhuantiRouter = require('./routes/zhuanti');
var zhifuRouter = require('./routes/zhifu');
var ytcfwRouter = require('./routes/ytcfw');
var errorRouter = require('./routes/error');
var payRouter = require('./routes/pay');
var lbwxqRouter = require('./routes/lbwxq');

//懿佳的 router服务
var allLoginRouter = require('./routes/allLogin');
var allRouter = require('./routes/lyjAll');


var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

// app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));


//梁徐超的 router

app.use('/lxcgouwuche', lxcgouwucheRouter);
app.use('/lxcgouwuchekong', lxcgouwuchekongRouter);
app.use('/lxcczzhifu', lxcczzhifuRouter);
app.use('/lxcchenggongdingdan', lxcchenggongdingdanRouter);
app.use('/lxcjifenshangcheng', lxcjifenshangchengRouter);
app.use('/lxcCGjoingouwuche', lxcCGjoingouwucheRouter);
app.use('/lxcdengdaizhifu', lxcdengdaizhifuRouter);
app.use('/lxcdingdanshouhuodizhi', lxcdingdanshouhuodizhiRouter);
app.use('/lxclibaiwu', lxclibaiwuRouter);
app.use('/lxcquerendingdanxinxi', lxcquerendingdanxinxiRouter);
app.use('/lxcshangjia', lxcshangjiaRouter);
app.use('/lxcshangjiabupeisong', lxcshangjiabupeisongRouter);
app.use('/lxcxiugaidizhi', lxcxiugaidizhiRouter);
app.use('/lxczhifuchenggongpsd', lxczhifuchenggongpsdRouter);
app.use('/lxcsanjiliandong', lxcsanjiliandongRouter);

//文博的 router
app.use('/lwb',lwbpersoncenterRouter);




//逸林的 router
app.use('/yyl',jfspxqRouter);
app.use('/zhuanti', zhuantiRouter);
app.use('/zhifu', zhifuRouter);

app.use('/ytcfw', ytcfwRouter);
app.use('/error', errorRouter);
app.use('/pay', payRouter);
app.use('/lbwxq', lbwxqRouter);


//懿佳的 router
app.use('/', allRouter);
app.use('/allLogin', allLoginRouter);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  next(createError(404));
});

// error handler
app.use(function(err, req, res, next) {
  // set locals, only providing error in development
  res.locals.message = err.message;
  res.locals.error = req.app.get('env') === 'development' ? err : {};

  // render the error page
  res.status(err.status || 500);
  res.render('error');
});

module.exports = app;
